#include "trace.h"

static uint64_t op_id = 0;

static std::ifstream trace_stream;

// static std::set<OP *> op_set;

static const int max_op_set_size = 512;

void init_trace(std::string file_name)
{
    trace_stream.open(file_name);
    assert(trace_stream.is_open());
    // op_set.clear();
}

OP *read_op()
{
    // assert(op_set.size() < max_op_set_size);
    OP *op = new OP;
    if (trace_stream.eof())
    {
        op->valid = false;
        memset((void *)(&op->trace),0, sizeof(op->trace));
        op->id = op_id++;
        return op;
    }
    trace_stream.read((char *)(&op->trace), sizeof(op->trace));
    op->id = op_id++;
    op->valid = true;
    // op_set.insert(op);
    // printf("read op:%ld\n",op->id);
    return op;
}

void free_op(OP *op)
{
    // printf("free op:%ld\n",op->id);
    // op_set.erase(op);
    delete op;
}



